package com.qf.service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.qf.dao.StudentMapper;
import com.qf.entity.Student;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class StudentServiceImpl implements StudentService{
    //在业务层中必须有dao层的对象
    @Autowired
    private StudentMapper studentMapper;

    @Override
    public List<Student> findAll() {
        return studentMapper.findAll();
    }

    @Override
    public List<Student> findById(Integer id) {
        return studentMapper.findById(id);
    }

    @Override
    public PageInfo<Student> findByPage(int pageNum, int pageSize) {
        //设置分页参数
        PageHelper.startPage(pageNum,pageSize);
        //执行查询操作
        List<Student> students = studentMapper.findAll();
        //基于查询结果，封装PageInfo对象返回
        return new PageInfo<>(students);
    }
}
